//
//  BaseTableViewCell.m
//  TestApplication
//
//  Created by Hanlingyu on 16/8/26.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "BaseTableViewCell.h"

@implementation BaseTableViewCell

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        
        [self setUp];
    }
    return self;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUp];
        NSUserDefaults *nightIsOn = [NSUserDefaults standardUserDefaults];
        NSString *isOn = [nightIsOn objectForKey:@"night"];
        
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(ON)
                                                     name:@"NIGHTON"
                                                   object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(OFF)
                                                     name:@"NIGHTOFF"
                                                   object:nil];
        
        if ([isOn isEqualToString:@"0"]) {
            
            self.contentView.backgroundColor = [UIColor whiteColor];
            
        }else if([isOn isEqualToString:@"1"]){
            
            self.contentView.backgroundColor = [UIColor colorWithRed:93/255.0 green:92/255.0 blue:101/255.0 alpha:1];
            
        }
    }
    return self;
}
- (void)setUp {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.contentView.backgroundColor = [UIColor whiteColor];
    
}



- (void)dealloc{

    
     [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NIGHTON" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NIGHTOFF"object:nil];


}





- (void)ON{
    self.contentView.backgroundColor =  [UIColor colorWithRed:93/255.0 green:92/255.0 blue:101/255.0 alpha:1];
}

- (void)OFF{
    
    self.contentView.backgroundColor =[UIColor whiteColor];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
